package main
import "fmt"

func gcd(a int,b int)(ans int){
	if a%b==0{
		return b
	} else {
		return gcd(b,a%b)
	}
}

func main(){
	var a,b int
	fmt.Scanf("%d%d",&a,&b)
	c:=gcd(a,b)
	fmt.Printf("%d\n",c)
}